package com.dq.domain.sys.user;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import com.dq.domain.sys.user.user.base.SysUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

import static com.dq.vo.baseVo.VO.inCaseNull;

/**
 * @author liuhui
 * @date 2019/9/17 0017 17:20:48
 */
@Data
@Entity
@ApiModel("签到记录")
public class UserSignOn extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("用户对象")
    @ManyToOne
    protected SysUser user;

    @ManyToOne
    protected SignOn signOn;

    @ApiModelProperty("获得积分")
    protected String integral;

    @Data
    @ApiModel(value = "签到视图")
    public static class Vo implements VO {
        @ApiModelProperty("用户对象")
        @ManyToOne
        private SysUser.Vo user;

        @ManyToOne
        private SignOn.Vo signOn;

        @ApiModelProperty("获得积分")
        private String integral;
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.user = (SysUser.Vo) inCaseNull(this.user, false);
        vo.signOn = (SignOn.Vo) inCaseNull(this.signOn, false);
        vo.integral = this.integral;
        return vo;
    }
}
